local M = {
    "nvim-treesitter/nvim-treesitter",
    build = ":TSUpdate",
    event = "BufReadPost",
    dependencies = {
        "andymass/vim-matchup", -- 增强 % 跳转（部分 Lua 支持）
    },
}
M.config = function()
    local configs = require "nvim-treesitter.configs"

    configs.setup {
        auto_install = true,
        ensure_installed = {
            "bash",
            "css",
            "git_rebase",
            "gitcommit",
            "gitignore",
            "go",
            "gomod",
            "gosum",
            "gowork",
            "html",
            "javascript",
            "json",
            "lua",
            "markdown",
            "markdown_inline",
            "rust",
            "toml",
            "typescript",
            "vim",
            "vue",
            "yaml",
        },
        matchup = { enable = true }, -- 启用标签匹配
        sync_install = false,
        highlight = { enable = true },
        indent = { enable = true },
        -- 启用增量选择
        incremental_selection = {
            enable = true,
            keymaps = {
                init_selection = "<CR>",
                node_incremental = "<CR>",
                node_decremental = "<BS>",
                scope_incremental = "<TAB>",
            },
        },
        autopairs = { enable = true },
        textobjects = {
            select = {
                enable = true,
                -- Automatically jump forward to textobj, similar to targets.vim
                lookahead = true,
            },
        },
    }
end

return M
